//
//  sendToVC.swift
//  Tinsecret_TW
//
//  Created by wanghui on 2018/11/1.
//  Copyright © 2018年 tst. All rights reserved.
//  发送给

import UIKit
import SnapKit
import SwiftyJSON

class sendToVC: UIViewController {
    
    var type:NSInteger? // 0: p2p  1:
    var memberCount:Int?
    var group:ChatSession!
    var msg:ChatMessage!
    var sessionServerId:Int = 0
    var chatcontact:ChatContact?
    var specialAvatar:String?
    
    lazy var tableView:UITableView = {
        let tableView = UITableView(frame: CGRect.zero, style: .grouped)
//        tableView.tableFooterView = UIView.init(frame: CGRect.zero)
        tableView.dataSource = (self as UITableViewDataSource)
        tableView.delegate = (self as UITableViewDelegate)
        
        tableView.register(UINib.init(nibName: "headerViewForsendvc", bundle: nil), forHeaderFooterViewReuseIdentifier: "headerViewForsendvc")
        tableView.register(UINib.init(nibName: "footviewForsendvc", bundle: nil), forHeaderFooterViewReuseIdentifier: "footviewForsendvc")
        tableView.register(tstPtPcell.self, forCellReuseIdentifier: "tstPtPcell")
        tableView.register(groupcell.self, forCellReuseIdentifier: "groupcell")
        tableView.register(chooseSesForTwo.self, forCellReuseIdentifier: "chooseSesForTwo")
        tableView.register(UINib(nibName: "chooseSesForTwo",bundle: nil), forCellReuseIdentifier: "chooseSesForTwo")
        tableView.register(UINib(nibName: "chooseSesForThree",bundle: nil), forCellReuseIdentifier: "chooseSesForThree")
        tableView.register(UINib(nibName: "chooseSeForFour",bundle: nil), forCellReuseIdentifier: "chooseSeForFour")
        tableView.register(UINib(nibName: "chooseSeForFive",bundle: nil), forCellReuseIdentifier: "chooseSeForFive")
        tableView.register(UINib(nibName: "chooseSeForSix",bundle: nil), forCellReuseIdentifier: "chooseSeForSix")
        tableView.register(UINib(nibName: "chooseSeForSeven",bundle: nil), forCellReuseIdentifier: "chooseSeForSeven")
        tableView.register(UINib(nibName: "chooseSeForEight",bundle: nil), forCellReuseIdentifier: "chooseSeForEight")
        tableView.register(UINib(nibName: "chooseSeForNine",bundle: nil), forCellReuseIdentifier: "chooseSeForNine")
        tableView.register(UINib(nibName: "contentCellForSendvc",bundle: nil), forCellReuseIdentifier: "contentCellForSendvc")
        
        tableView.register(UINib(nibName: "ChatpicLeftcell",bundle: nil), forCellReuseIdentifier: "ChatpicLeftcell")
        tableView.register(UINib(nibName: "ChatCustomEmotionLeftCell",bundle: nil), forCellReuseIdentifier: "ChatCustomEmotionLeftCell")
        tableView.register(UINib(nibName: "ChatVideoLeftCell",bundle: nil), forCellReuseIdentifier: "ChatVideoLeftCell")


        tableView.rowHeight = 70
//        tableView.backgroundColor = RGBA(r: 255/255, g: 255/255, b: 255/255, a: 1)
        
        tableView.layer.cornerRadius = 5
        tableView.layer.masksToBounds = true
        tableView.showsVerticalScrollIndicator = false
        tableView.showsHorizontalScrollIndicator = false
        return tableView
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        self.setupUI()
    }
    
    override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
    }

}

extension sendToVC {
    func setupUI() {
      self.view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.6)
       self.view.addSubview(tableView)
        
        tableView.snp.makeConstraints { make in
            make.left.equalTo(self.view).offset(30)
            make.right.equalTo(self.view).offset(-30)
            if msg?.messageType == .img {
                make.height.equalTo(330)
            }else {
                make.height.equalTo(220)
            }
            make.centerY.equalTo(self.view)
        }
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.dismiss(animated: true, completion: nil)
    }
}

extension sendToVC: UITableViewDataSource, UITableViewDelegate{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 2
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if indexPath.row == 0 {
            if type == 0 { //p2p
                let cell = tableView.dequeueReusableCell(withIdentifier: "tstPtPcell", for: indexPath) as! tstPtPcell
                cell.nameLabel.text = self.chatcontact?.displayName ?? self.group.sessionName
                if self.chatcontact?.avatar != nil {
                     cell.headimage.kf.setImage(with: Common.avatarUrl(self.chatcontact?.avatar ?? "") ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                }else {
                    cell.headimage.kf.setImage(with: Common.avatarUrl(self.specialAvatar ?? "") ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                }
               
                return cell
            }else {
                switch memberCount {
                case 1:
                    let cell = tableView.dequeueReusableCell(withIdentifier: "groupcell", for: indexPath) as! groupcell
                    cell.nameLabel.text = self.group?.sessionName
                    cell.headimage.kf.setImage(with: Common.avatarUrl(self.group!.avatars[0] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    return cell
                case 2:
                    let cell = tableView.dequeueReusableCell(withIdentifier: "chooseSesForTwo", for: indexPath) as! chooseSesForTwo
                    cell.namelabel.text = self.group?.sessionName
                    cell.firstimage.kf.setImage(with: Common.avatarUrl(self.group!.avatars[0] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.secondimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[1] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    return cell
                case 3:
                    let cell = tableView.dequeueReusableCell(withIdentifier: "chooseSesForThree", for: indexPath) as! chooseSesForThree
                    cell.namelabel.text = self.group?.sessionName
                    cell.firstimage.kf.setImage(with: Common.avatarUrl(self.group!.avatars[0] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.secondimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[1] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.thirdimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[2] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    return cell
                case 4:
                    let cell = tableView.dequeueReusableCell(withIdentifier: "chooseSeForFour", for: indexPath) as! chooseSeForFour
                    cell.namelabel.text = self.group?.sessionName
                    cell.firstimage.kf.setImage(with: Common.avatarUrl(self.group!.avatars[0] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.secondimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[1] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.thirdimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[2] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fourthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[3] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    return cell
                case 5:
                    let cell = tableView.dequeueReusableCell(withIdentifier: "chooseSeForFive", for: indexPath) as! chooseSeForFive
                    cell.namelabel.text = self.group?.sessionName
                    cell.firstimage.kf.setImage(with: Common.avatarUrl(self.group!.avatars[0] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.secondimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[1] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.thirdimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[2] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fourthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[3] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fifthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[4] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    return cell
                case 6:
                    let cell = tableView.dequeueReusableCell(withIdentifier: "chooseSeForSix", for: indexPath) as! chooseSeForSix
                    cell.namelabel.text = self.group?.sessionName
                    cell.firstimage.kf.setImage(with: Common.avatarUrl(self.group!.avatars[0] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.secondimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[1] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.thirdimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[2] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fourthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[3] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fifthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[4] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.sixthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[5] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    return cell
                case 7:
                    let cell = tableView.dequeueReusableCell(withIdentifier: "chooseSeForSeven", for: indexPath) as! chooseSeForSeven
                    cell.namelabel.text = self.group?.sessionName
                    
                    cell.firstimage.kf.setImage(with: Common.avatarUrl(self.group!.avatars[0] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.secondimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[1] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.thirdimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[2] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fourthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[3] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fifthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[4] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.sixthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[5] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.sevenimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[6] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    return cell
                case 8:
                    let cell = tableView.dequeueReusableCell(withIdentifier: "chooseSeForEight", for: indexPath) as! chooseSeForEight
                    cell.namelabel.text = self.group?.sessionName
                    cell.firstimage.kf.setImage(with: Common.avatarUrl(self.group!.avatars[0] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.secondimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[1] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.thirdimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[2] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fourthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[3] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fifthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[4] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.sixthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[5] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.sevenimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[6] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.eighthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[7] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    return cell
                case 9:
                    let cell = tableView.dequeueReusableCell(withIdentifier: "chooseSeForNine", for: indexPath) as! chooseSeForNine
                    cell.namelabel.text = self.group?.sessionName
                    cell.firstimage.kf.setImage(with: Common.avatarUrl(self.group!.avatars[0] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.secondimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[1] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.thirdimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[2] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fourthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[3] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.fifthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[4] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.sixthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[5] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.sevenimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[6] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.eighthimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[7] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    cell.nineimg.kf.setImage(with: Common.avatarUrl(self.group!.avatars[8] ) ?? URL(string: "localhost")!, placeholder: UIImage.init(named: "defaultAvatar"),options: [.processor(CryptorProcessor())])
                    return cell
                default:
                    let cell = tableView.dequeueReusableCell(withIdentifier: "groupcell", for: indexPath) as! groupcell
                    cell.nameLabel.text = self.group?.sessionName
                    cell.headimage.image = UIImage.init(named: "timg")
                    return cell
                }
            }
            
        }else {
            if (msg?.messageType == .text) {
                let cell = tableView.dequeueReusableCell(withIdentifier: "contentCellForSendvc", for: indexPath) as! contentCellForSendvc
                cell.contentLabel.text = msg?.text
                return cell
            }else if (msg?.messageType == .img) {
                let cell = tableView.dequeueReusableCell(withIdentifier: "ChatpicLeftcell", for: indexPath) as! ChatpicLeftcell
                cell.setup(model: msg!)
                
                cell.avatar.isHidden = true
                cell.namelabel.isHidden = true
                cell.activityindicator.isHidden = true
                cell.sendfailureBtn.isHidden = true
                cell.imgtopConstraint.constant = 10
                cell.pic.centerX = self.view.centerX
                cell.createTimelabel.isHidden = true
                cell.transitionToShow()
                
                return cell
            }else if(msg?.messageType == .sticker) {
                let cell = tableView.dequeueReusableCell(withIdentifier: "ChatCustomEmotionLeftCell", for: indexPath) as! ChatCustomEmotionLeftCell
                cell.setup(model: msg!)

                cell.avatar.isHidden = true
                cell.namelabel.isHidden = true
                cell.activityindicator.isHidden = true
                cell.sendfailureBtn.isHidden = true
                cell.imgtopConstraint.constant = 10
                cell.pic.centerX = self.view.centerX
                cell.createTimelabel.isHidden = true
                return cell
            }else if(msg?.messageType == .file) {
                let cell = tableView.dequeueReusableCell(withIdentifier: "contentCellForSendvc", for: indexPath) as! contentCellForSendvc
                cell.contentLabel.text = NSLocalizedString("[文件]",comment:"[文件]") + (msg?.fileName)! + ".\(msg?.ext ?? "")"
                return cell
            }else if(msg?.messageType == .video) {
                let cell = tableView.dequeueReusableCell(withIdentifier: "ChatVideoLeftCell", for: indexPath) as! ChatVideoLeftCell
                let json = JSON(parseJSON: msg.text ?? "")
                print(" == \(json["fileName"].stringValue)")
                let videoFileName = json["fileName"].stringValue
                cell.urlFromSendVC = Common.getLocalUrl(videoFileName, file: "videoUrl")

                cell.pic.image = msg.videoThumbnail
                cell.picWidthContraint.constant = msg.videoWidth
                cell.picHeightContraint.constant = msg.videoHeight

                cell.avatar.isHidden = true
                cell.namelabel.isHidden = true
                cell.activityindicator.isHidden = true
                cell.sendfailureBtn.isHidden = true
                cell.imgtopConstraint.constant = 10
                cell.pic.centerX = self.view.centerX
                cell.createTimelabel.isHidden = true

                return cell
            }
            let cell = tableView.dequeueReusableCell(withIdentifier: "contentCellForSendvc", for: indexPath) as! contentCellForSendvc
            cell.contentLabel.text = msg?.text
            return cell
            
        }
    }
    
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
            let headview = Bundle.main.loadNibNamed("headerViewForsendvc", owner: nil, options: nil)?.last as! UIView
            return headview
    }
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 30
    }
    
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
         let footview = Bundle.main.loadNibNamed("footviewForsendvc", owner: nil, options: nil)?.last as! footviewForsendvc
        footview.actionDelegate = self
        return footview
    }
    
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 50
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if indexPath.row == 1 {
            if msg?.messageType == .img {
                return 170
            }else if msg?.messageType == .sticker {
                return 130
            } else if msg?.messageType == .video {
                return msg.videoHeight
            }
        }
       return 70
      }
}

extension sendToVC: footviewForsendvcDelegate{
    
    func cancelAction() {
        self.dismiss(animated: true, completion: nil)
    }
    
    func sendAction() {
        let service = ChatService()
        
        let toSendMsg:ChatMessage
        if self.group != nil {
//            print("\(msg.messageType)")
           toSendMsg = ChatMessage(sessionId: self.group.session.sessionServerId, from: (AppStatusManager.instance.userLoginStatus.1 ?? 0),fromName:AppStatusManager.instance.userLoginStatus.2!, me:  1,messageType:msg.messageType)
            toSendMsg.chatType = group.session.chatType
        }else {
           toSendMsg = ChatMessage(sessionId: self.sessionServerId, from: (AppStatusManager.instance.userLoginStatus.1 ?? 0),fromName:AppStatusManager.instance.userLoginStatus.2!, me:  1,messageType:msg.messageType)
            toSendMsg.chatType = .p2p
        }
        
//        toSendMsg.avatar = msg.avatar
        toSendMsg.text = msg.text
        if msg.messageType == .file{
            toSendMsg.storeFile = msg.storeFile
            toSendMsg.fileSize = msg.fileSize
            toSendMsg.ext = msg.ext
            toSendMsg.fileName = msg.fileName
        }else if msg.messageType == .img {
            toSendMsg.imgFileName = msg.imgFileName
            toSendMsg.imgData = msg.imgData
//            toSendMsg.download =
            toSendMsg.imgSize = msg.imgSize
            toSendMsg.memSize = msg.memSize
            toSendMsg.status = msg.status
        }else if msg.messageType == .sticker {
            toSendMsg.stickerName = msg.stickerName
            toSendMsg.stickerPath = msg.stickerPath
            toSendMsg.category = msg.category
        }
   
//        toSendMsg.chatType = group.session.chatType
        if (toSendMsg != nil) {
            DispatchQueue.global().async {
                service.sendMsgDirect(msg: toSendMsg,result: { msg in
                if self.sessionServerId == toSendMsg.sessionId {
                    NotificationCenter.default.post(name: addRowNotiName, object: nil, userInfo: ["msg": toSendMsg])
                    }
                NotificationCenter.default.post(name: closeCurrentVCNoti, object: nil, userInfo: nil)
                })
            }
        }
        DispatchQueue.main.async {
            self.dismiss(animated: true, completion: nil)
        }
    }
}
